package cn.wizzer.app.user.modules.models;

import cn.wizzer.app.user.modules.models.enums.MsgStatusEnum;
import cn.wizzer.app.user.modules.models.enums.MsgTypeEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.integration.json4excel.annotation.J4EIgnore;

@Data
@Table("user_chat_msg")
@TableIndexes({@Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false),
        @Index(name = "index_userId", fields = {"userId"}, unique = false)})
@TableMeta("{mysql-charset:'utf8mb4'}")
public class UserChatMsg extends BaseModel {

    @Column
    @Name
    @Comment("ID")
    @J4EIgnore
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column("userId")
    @ColDefine(type = ColType.VARCHAR,width = 32)
    @Comment("发送人")
    private String userId;

    @Column
    @ColDefine(type = ColType.VARCHAR,width = 32)
    @Comment("接收人")
    private String toUser;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    private Long ctAt;

    @Column
    @ColDefine(type = ColType.VARCHAR,width = 16)
    @Comment("消息类型")
    @Default("TEXT")
    private MsgTypeEnum type;

    @Column
    @ColDefine(type = ColType.VARCHAR,width = 16)
    @Comment("消息状态")
    @Default("UN_READ")
    private MsgStatusEnum status;

    @Column
    @ColDefine(type = ColType.VARCHAR,width = 1024)
    @Comment("消息内容")
    private String content;

}
